package com.leyou.item.web;

import com.leyou.item.pojo.Category;
import com.leyou.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@CrossOrigin
@RestController
@RequestMapping(value = "/category",method = RequestMethod.GET)
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * @param pid 父节点id
     * 根据父节点id查询商品的分类。
     *
     * */

    @RequestMapping("/list")
    public ResponseEntity<List<Category>> queryCategoryListByPid(@RequestParam("pid") long pid){
        return ResponseEntity.ok(categoryService.queryCategoryListByPid(pid));
    }
}
